//
//  SetSrecyViewController.m
//  BGM
//
//  Created by liuqin on 2018/11/28.
//  Copyright © 2018年 com.alirtc.demo. All rights reserved.
//

#import "SetSrecyViewController.h"
#import "Common.h"
#import "MeTableViewCell.h"
#import "PushShieldFriendViewController.h"


@interface SetSrecyViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, copy)NSArray *messageArray;
@property (nonatomic, copy)NSString *rightUser;

@property (nonatomic, strong)UITableView *myTableView;


@end

@implementation SetSrecyViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navview.hidden = NO;
    self.titleBtn.hidden = NO;
    CGRect rect = self.titleBtn.frame;
    rect.size.width = rect.size.width+70;
    self.titleBtn.frame = rect;
    [self.titleBtn setTitle:@"隐私设置" forState:UIControlStateNormal];
    
    
//    setfillterUsers
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(setfillterUsers:) name:@"setfillterUsers" object:nil];
    
    self.messageArray = @[@"屏蔽好友",@"切断人脉链"];
    self.myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, self.navview.frame.size.height, SCREENW, SCREENH-self.navview.frame.size.height)];
    self.myTableView.backgroundColor = [UIColor clearColor];
    self.myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    self.myTableView.scrollEnabled = NO;
    [self.view addSubview:self.myTableView];
}
#pragma mark UITABLEVIEWDELEAGE
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 2;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 50;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *identifier = @"MeTableViewCell";
    MeTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[MeTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.iconBtn.hidden = NO;
        cell.rightLabel.hidden = NO;
        cell.contentLabel.frame = CGRectMake(15, 0, 300, 50);
        cell.line.frame = CGRectMake(15, 50-0.3, SCREENW, 0.3);
        
   
        cell.rightLabel.textColor = bgmsmallColor;
        cell.rightLabel.font = [UIFont systemFontOfSize:13];
        cell.rightLabel.frame =CGRectMake(120, 0, SCREENW-160, 50);
    }
    cell.contentLabel.text =[self.messageArray objectAtIndex:indexPath.row];
    if(indexPath.row==0){
        cell.rightLabel.text =  self.rightUser.length>0?self.rightUser:@"不让他看你发布的帮忙信息";
    }else{
        cell.rightLabel.text =  @"不让你的朋友看他发布的帮忙";
    }

    return cell;
    
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    int i = (int)indexPath.row;
    switch (i) {
        case 0:
        {
            PushShieldFriendViewController *vc = [[PushShieldFriendViewController alloc]init];
            vc.vcTitle = @"屏蔽好友";

            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 1:
        {
            PushShieldFriendViewController *vc = [[PushShieldFriendViewController alloc]init];
            vc.vcTitle = @"切断人脉链";
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
       
        default:
            break;
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (void)setfillterUsers:(NSNotification *)noti{
    NSString *userName = (NSString *)noti.object;
    if (userName.length>0) {
        self.rightUser = [userName substringWithRange:NSMakeRange(0, userName.length-1)];
        [self.myTableView reloadData];
    }
    
    
}
- (void)dealloc{
    [[NSNotificationCenter defaultCenter]removeObserver:self];
}
@end
